#include "widget.h"
#include "ui_widget.h"

#include <QDebug>
#include <QSqlError>


Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    db = QSqlDatabase::addDatabase("QMYSQL");
    //db->addDatabase("QMYSQL");
    db.setDatabaseName("springcloud_template");
    db.setPort(3306);
    db.setHostName("localhost");
    db.setUserName("root");
    db.setPassword("123456");
    if(db.open()){
        qDebug()<<"mysql connect ok";
    }else {
        qDebug()<<db.lastError().text();
        qDebug()<<"mysql connect failed";
    }

}

Widget::~Widget()
{
    delete ui;
}

